const fs = require('fs')

/**
 * promise封装异步读文件
 * @returns
 */
const readFilePromise = () => {
	return new Promise((resolve, reject) => {
		fs.readFile('old.txt', 'utf-8', function (err, data) {
			if (err) {
				reject(err)
				return
			}
			resolve(data.toString())
		})
	})
}

async function readFileAsync() {
	// then方法处理成功读文件结果
	const data = await readFilePromise()
    console.log(data);
}

readFileAsync()
